package com.aerozhonghuan.logisticsmall.framework.hybrid.actions;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.aerozhonghuan.logisticsmall.framework.hybrid.NewWebviewFragment;
import com.aerozhonghuan.logisticsmall.framework.hybrid.SimpleActionHandler;
import com.aerozhonghuan.logisticsmall.framework.hybrid.bean.JsMobileAgentConstants;
import com.aerozhonghuan.logisticsmall.modules.common.event.DefalutHttpExceptionAlert;
import com.aerozhonghuan.logisticsmall.modules.user.logic.UserInfoManager;
import com.aerozhonghuan.foundation.eventbus.EventBusManager;
import com.aerozhonghuan.hybrid.XJsCallback;
import com.umeng.analytics.MobclickAgent;

import org.json.JSONObject;

/**
 * 描述
 * 作者 Zhang Yonghui
 * 创建日期 2019/1/21
 */
public class LogoutActionHandler extends SimpleActionHandler {

    public LogoutActionHandler(NewWebviewFragment fragment) {
        super(JsMobileAgentConstants.FLAG_LOGOUT, fragment);
    }

    @Override
    public void handleAction(@NonNull String action, @Nullable JSONObject params, @Nullable XJsCallback callBack) {
        EventBusManager.post(new DefalutHttpExceptionAlert("您的账号已在其它设备登录，如非本人操作，请修改密码！"));
        UserInfoManager.logout(getActivity());
        MobclickAgent.onProfileSignOff();//帐号统计-登出
    }
}
